package utils;

import java.awt.Dimension;
import java.awt.Window;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.InetAddress;
import java.net.UnknownHostException;

public class Util {

	  public static void centerWindow(Window paramWindow)
	  {
	    Dimension localDimension = paramWindow.getToolkit().getScreenSize();
	    paramWindow.setLocation(localDimension.width / 2 - paramWindow.getWidth() / 2, localDimension.height / 2 - paramWindow.getHeight() / 2);
	  }

	  public static boolean checkHost(String paramString)
	  {
	    try
	    {
	      InetAddress.getByName(paramString);
	      return true;
	    }
	    catch (UnknownHostException localUnknownHostException)
	    {
	    }
	    return false;
	  }

	  public static void writeFile(String paramString1, String paramString2)
	    throws IOException
	  {
	    PrintWriter localPrintWriter = new PrintWriter(new BufferedWriter(new FileWriter(paramString1)));
	    localPrintWriter.print(paramString2);
	    localPrintWriter.close();
	  }

	  public static String readFile(String paramString, Object paramObject)
	    throws IOException
	  {
	    StringBuffer localStringBuffer = new StringBuffer();
	    ClassLoader localClassLoader = paramObject.getClass().getClassLoader();
	    InputStream localInputStream = localClassLoader.getResourceAsStream(paramString);
	    BufferedReader localBufferedReader = new BufferedReader(new InputStreamReader(localInputStream));
	    String str;
	    while ((str = localBufferedReader.readLine()) != null)
	    {
	      localStringBuffer.append(str);
	      localStringBuffer.append("\n");
	    }
	    localBufferedReader.close();
	    return localStringBuffer.toString();
	  }
}
